<!DOCTYPE html>
<html>
	<head>
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
		<meta name="renderer" content="webkit">
		<title>预览</title>
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="css/custom.css" />
		<link rel="stylesheet" type="text/css" href="css/jquery.imageLabel.min.css" />
		<link rel="stylesheet" type="text/css" href="css/style.css" />
		<script type="text/javascript">


		</script>
		<link rel="stylesheet" href="css/jquery.imageLabel.min.css">
		<link rel="stylesheet" href="css/custom.css">

	</head>
	<body>
	<!--	<input type="hidden" id="imgUrl" value='//172.168.252.57:8080/sxgov/ImageShowServlet?fileOid=' />-->
		<div class="scyd" id="scyd">
		</div>
<!--		<div class="prev" title="上一张" onclick="prev()">
			<img src="//172.168.252.57:8080/sxgov/css/images/left.png" />
		</div>
		<div class="next" title="下一张" onclick="next()">
			<img src="//172.168.252.57:8080/sxgov/css/images/right.png" />
		</div>
		<div class="count-num">
			<div>共<span id="countNum">0</span>页，第<span id="curNum">0</span>页</div>
		</div>-->

		<script src="js/jquery-3.5.1.min.js" type="text/javascript"></script>
		<script src="js/zDialog/zDialog.js"></script>
		<script src="js/jquery.imageLabel.min.js"></script>
     <script src="js/common.js" type="text/javascript" charset="utf-8"></script>
  <script src="../common.js" type="text/javascript" charset="utf-8"></script>
		<script>
      var VUE_APP_BASE_API=commonUrl.VUE_APP_BASE_API;
      //var VUE_APP_KSTB_ROUTE_PATH=commonUrl.VUE_APP_KSTB_ROUTE_PATH;
      var VUE_APP_KSTB_ROUTE_PATH="";
      //var VUE_APP_BASE_API='/dev-api';
     //var VUE_APP_KSTB_ROUTE_PATH='/dzcpt-lss/zc';
     //var VUE_APP_KSTB_ROUTE_PATH="http://172.168.252.43:9090/zc";
      //获取参数
      function getURLParameter(name) {
        return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
      }
      var  materiaOid = getURLParameter("materiaOid");
      var serviceOid=getURLParameter("serviceOid");
      var  ahsSamplePicInfoOid = getURLParameter("ahsSamplePicInfoOid");
      var attaOid=getURLParameter("attaOid");
     var comboDirectoryOid=getURLParameter("comboDirectoryOid");
      var imgUrlinfo="";
			$(function() {

        getZcUrl();

        function getZcUrl(){
          var code="KSTB_ROUTE_URL" ;
          var urlImg = VUE_APP_BASE_API+'/settings/security/config/getSysConfigByCode';
          var dataimg = {
            "code": code,
          }
          $.ajax({
            url: urlImg, //请求地址
            type: "get", //请求方式
            data:dataimg,
            dataType:'json',
            success: function(data) { //成功回调
              VUE_APP_KSTB_ROUTE_PATH=data.data.value;
              getAttaUrl();
            },
            fail: function(data) {
              console.log('fail')
            }
          });
        }


        //这个设置一定要在imageLabel 初始化后面
        $('.imageLabel-box').css("width", "80%");


        function  getAttaUrl() {
            var urlImg = VUE_APP_BASE_API + '/platform/security/atta/nologin/getByAttaOid';
            var dataimg = {
              "attaOid": attaOid,
            }
            $.ajax({
              url: urlImg, //请求地址
              type: "get", //请求方式
              data: dataimg,
              dataType: 'json',
              success: function (data) { //成功回调
                imgUrlinfo = data.data.fastdfsNginxUrl;
                getExaminePointCardingList(imgUrlinfo);//获取审查要点列表
              },
              fail: function (data) {
                console.log('fail')
              }
            });
        }
        //获取审查要点列表
        function  getExaminePointCardingList(imgUrlinfo){
         var url=VUE_APP_KSTB_ROUTE_PATH+"/examinePointCarding/getExaminePointCardingList";
          var data = {
            "attaOid": attaOid,
            "ahsSamplePicInfoOid": ahsSamplePicInfoOid,
            "serviceOid":serviceOid,
          }
          $.get( url, data, function(data, textStatus, jqXHR){

            var epcData = data.data.examinePointCardingList;
            if (!epcData || epcData.length === 0) {
              initData(attaOid,epcData,imgUrlinfo);//初始化加载数据
              /*$("body").html('<div class="noDate"></div>');*/
            } else {
              if (!epcData || epcData.length === 1) {
                $('.prev,.next').hide();
              }
              initData(attaOid,epcData,imgUrlinfo);//初始化加载数据
            }
          },'json');
        }


			});
			//初始化加载数据
			var GLOBAL_DATA = [];
			var GLOBAL_CUR_NUM = 0;
			var initData = function(attaOid,epcData,imgUrlinfo) {
/*				GLOBAL_DATA = epcData;
        GLOBAL_DATA.attaOid=attaOid;
        GLOBAL_DATA.list=epcData;*/
				loadData(attaOid, epcData,imgUrlinfo);
				loadPageData();
			}
			/*
				加载一个图片 和 审查要点数据,传入 attaOid，和 审查要点数据
			*/
			var loadData = function(attaOid, epcList,imgUrlinfo) {

				//拼接附件的路径
        var imgUrl =imgUrlinfo;
				window.c = imageLabel({
					img: imgUrl,
					shade: false,
					preview: true,
					showBut: false,
					only: false,
					editPop: false,
					data: epcList
				});
				$('.imageLabel-box').css("width", "80%");
				loadRightEpcData(epcList);
			}

			//加载右侧的审查要点数据
			var loadRightEpcData = function(epcList) {

				//操作之前先清空
				$('#scyd').html('');

				//加载 右侧的审查数据
				var htmlStr = '<div class="scyd-info">审查要点说明</div>';
				if (epcList && epcList.length > 0) {
					htmlStr += '<div class="scyd-data" id="scydData">';

					for (var i = 0; i < epcList.length; i++) {
						var item = epcList[i];
						htmlStr +=
							`<div class="scyd-data-item">
					<div class="scyd-data-title">审查要点<span style="color:red;margin-left:3px;font-weight: bold;">` +
							item.name + `</span>:</div>
					<div class="scyd-data-content">
						<div class="scyd-data-view">` + item.examineInfo +
							`</div>
					</div>
				</div>`;
					}
					htmlStr += `</div>`;

				} else {
					htmlStr +=
						`<div class="scyd-no-data" id="scydNoData">
						<div><img src="img/no-message.png"/></div>
						<div class="noDate"></div>
					   </div>`;
				}
				$('#scyd').append(htmlStr);
			}

			//上一页
			var prev = function() {
				if (GLOBAL_CUR_NUM === 0) {
					//提示已经是第一页
					Dialog.typeAlert(2, "已经是第一张图片!");
				} else {
					GLOBAL_CUR_NUM = GLOBAL_CUR_NUM - 1;
					var item = GLOBAL_DATA[GLOBAL_CUR_NUM];
					var attaOid = item.attaOid;
					var epcList = item.list;
					loadData(attaOid, epcList);
					loadPageData();
				}
			}

			//下一页
			var next = function() {
				if (GLOBAL_CUR_NUM === GLOBAL_DATA.length - 1) {
					Dialog.typeAlert(2, "已经是最后一张图片!");
				} else {
					GLOBAL_CUR_NUM = GLOBAL_CUR_NUM + 1;
					var item = GLOBAL_DATA[GLOBAL_CUR_NUM];
					var attaOid = item.attaOid;
					var epcList = item.list;
					loadData(attaOid, epcList);
					loadPageData();
				}
			}

			//加载翻页的数据
			var loadPageData = function() {
				$("#countNum").text(1);
				$("#curNum").text(1);
			}
		</script>
	</body>
</html>
